package com.dy.video.mapper;

import com.dy.video.Video;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import entity.vo.videoVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author DELL
* @description 针对表【video】的数据库操作Mapper
* @createDate 2024-11-21 14:28:54
* @Entity video.domain.Video
*/
public interface VideoMapper extends BaseMapper<Video> {

    @Select("select v.*, u.name uname,u.image img,v.id userid from video v left join user u on v.uid=u.id")
    List<videoVo> findAll();

    @Update("update video set comnum=comnum+1 where id=#{id}")
    void updateByComnum(@Param("id") Integer vid);

    @Select("select v.*, u.name uname,u.image img,u.number,u.get_thumbs_up thumbscount,u.fans,u.focus from video v left join user u on v.uid=u.id where v.uid = #{uid}")
    List<videoVo> findByVideo(Integer uid);

    List<videoVo> findAll1(@Param("video") Video v);

    @Select("SELECT \n" +
            "    g1.uid AS user1, \n" +
            "    g1.user_uid AS user2,v.*,u.`name` uname\n" +
            "FROM \n" +
            "    gz g1\n" +
            "JOIN \n" +
            "    gz g2\n" +
            "ON \n" +
            "    g1.uid = g2.user_uid AND g1.user_uid = g2.uid JOIN video v on v.uid=g2.uid LEFT JOIN user u on u.id=v.uid where g1.uid = 1")
    List<videoVo> findAll2();

    @Select("select v.*, u.name uname,u.image image,v.id userid from video v left join user u on v.uid=u.id  GROUP BY u.id")
    List<Video> findList(Video video);
}




